#!/bin/bash
NET=172.16.80
user=root
password=Cykk2012..
for ID in 151 152 153 ;do
ip=$NET.$ID
expect <<EOF
set timeout 20
spawn scp kernel.sh $user@$ip:~
expect {
"yes/no" { send "yes\n";exp_continue }
"password" { send "$password\n" }
}
expect eof
spawn ssh $user@$ip
expect {
"yes/no" { send "yes\n";exp_continue }
"password" { send "$password\n" }
}
expect "#" { send "bash kernel.sh && echo  "安装完成" && exit\n" }
expect eof
EOF
done
